package ControlLayer;

import ModelLayer.Lease;
import ModelLayer.LeaseRecords;
import ModelLayer.RealException;



public class LeaseCtr {
	
	private LeaseRecords leaseRecords;
	
	public LeaseCtr() 
	{
		leaseRecords = LeaseRecords.getInstance();
	}
	
	public int createLease(int customerId, int employeeId, long startDate, long endDate) throws RealException
	{
		
		return leaseRecords.createLease(customerId, employeeId, startDate, endDate);
	}
	
	public Lease getlease(int id) throws RealException
	{
		return leaseRecords.getLease(id);
	}
	
	public void removeLease(int id) throws RealException
	{
		leaseRecords.removeLease(id);
	}
	
	public void updateLease(int id, int choise, String value) throws RealException
	{
		leaseRecords.updateLease(id, choise, value);
	}
	
	public double getLeasePrice(int id) throws RealException
	{
		return leaseRecords.getLease(id).getFinalPrice();
	}
	
	public String printLease(int id) throws RealException
	{
		return leaseRecords.getLease(id).toString();
	}
	
	public void returnLease(int id, String returnDate) throws RealException
	{
		leaseRecords.returnLease(id, returnDate);
	}
	
	public void hasPickup(int leaseid) throws RealException
	{
		leaseRecords.getLease(leaseid).setPickup(true);
	}
	
	public void noPickup(int leaseid, String dAddress) throws RealException
	{
		leaseRecords.getLease(leaseid).setPickup(false);
		leaseRecords.getLease(leaseid).setdAddress(dAddress);
	}
	
	
	
	
	public void addLeaseItemUnit(int leaseId, int leaseItemId, int serialNo) throws RealException
	{
		leaseRecords.getLease(leaseId).addLeaseItemUnit(leaseItemId, serialNo);
	}
	
	public void removeLeaseItemUnit(int leaseId, int leaseItemId, int serialNo) throws RealException
	{
		leaseRecords.getLease(leaseId).removeLeaseItemUnit(leaseItemId, serialNo);
	}
	
	public String getLeaseItemUnitsInfo(int leaseId) throws RealException
	{
		return leaseRecords.getLease(leaseId).listAllLeaseItemUnits();
	}
	
	
	
	
	public String printAllBorrowedLease(){
		return leaseRecords.printAllBorrowedLeaseInfo();
	}
	
	public String printAllReturnedLease() {
		return leaseRecords.printAllReturnedLeaseInfo();
	}
	

}
